﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DXApplicationTangche.UC.项目成果管理.service;
using DXApplicationTangche.UC.款式管理.service;
using DXApplicationTangche.UC.订单.service;

namespace DXApplicationTangche.UC.订单一览新.改版
{
    public partial class Form改版完成 : DevExpress.XtraEditors.XtraForm
    {
        private String batchNo;
        private Boolean is改版 = true;
        private StyleInformationDTO styleInformationDTO;
        public DTO返回值判断 DTO返回值判断 = new DTO返回值判断();
        public Form改版完成(String batchNo)
        {
            InitializeComponent();
            this.batchNo = batchNo;
        }

        public Form改版完成(
            Boolean is改版,
            StyleInformationDTO styleInformationDTO
            )
        {
            InitializeComponent();
            this.is改版 = is改版;
            this.styleInformationDTO = styleInformationDTO;
        }

        private void textBox扫描工牌_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                if (!String.IsNullOrWhiteSpace(this.textBox扫描工牌.Text))
                {
                    try
                    {
                        //判断扫描的工牌是否正确
                        String mnemonic = 项目成果Service.get判断扫描员工码是否正确(this.textBox扫描工牌.Text.Trim());
                        if (String.IsNullOrWhiteSpace(mnemonic))
                        {
                            this.textBox扫描工牌.Clear();
                            MessageBox.Show("扫描员工码错误，请重新扫描");
                            return;
                        }
                        if (is改版)
                        {
                            //  改版完成
                            改版Service.get改版完成(this.batchNo, this.textBox扫描工牌.Text.Trim());
                        }
                        else
                        {
                            //  新建款式
                            this.DTO返回值判断 = 款式Service.createStyleInfoWithStyleInformationDTO(this.styleInformationDTO.build(mnemonic));
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    this.textBox扫描工牌.Clear();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("请扫描工牌");
                }
            }
        }
    }
}